import Link from "next/link"; import { type BillingInvoices, getBillingInvoices, getViewerSession } from "@/lib/popiart-api"; import { type Locale } from "@/lib/site-content"; export default async function BillingSuccessPage({ params, searchParams, }: { params: Promise<{ locale: string }>; searchParams: Promise<{ kind?: string; provider?: string; trade_no?: string }>; }) { const { locale } = await params; const { kind, provider, trade_no: tradeNo } = await searchParams; const typedLocale = locale as Locale; const isZh = typedLocale === "zh"; const session = await getViewerSession(); let invoices: BillingInvoices | null = null; if (session && tradeNo) { try { invoices = await getBillingInvoices({ keyword: tradeNo, page: 1, pageSize: 10 }); } catch { invoices = null; } } const matchedOrder = (invoices?.subscription_orders.items || []).find((item) => String(item.trade_no || "") === String(tradeNo || "")) || (invoices?.point_orders.items || []).find((item) => String(item.trade_no || "") === String(tradeNo || "")); return (
{isZh ? "订单状态已切换为成功。你可以继续回到控制台或账单中心查看最新订阅、积分和订单历史。" : "The order has completed successfully. Continue to the console or billing center to review the latest subscription, credits, and order history."}